<%--
$Id: book-chapter-edit.jsp 24 2011-06-17 13:31:30Z feigme $
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/commons/taglibs.jsp" %>
<%@ taglib prefix="iary" uri="/WEB-INF/tld/pagination.tld" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><fmt:message key="user.manager"/></title>
<link href="${ctx }/css/admin/admin.css" rel="stylesheet" type="text/css" />
</head>
<body>
<br/>
<form:form action="${ctx }/admin/bookChapter/edit.do" method="post">
<input name="bookId" type="hidden" value="${chapterCommand.bookId }"/>
<input name="chapterId" type="hidden" value="${chapterCommand.chapterId }"/>
<input name="orpath" type="hidden" value="${chapterCommand.path }"/>
<table class="usertableborder" cellspacing="1" cellpadding="3" width="96%" align="center" border="0">
	<tr>
		<th colspan="6"><fmt:message key="common.create"/><fmt:message key="book.chapter"/></th>
	</tr>
	<tr>
		<td class="usertablerow2"><fmt:message key="book.chapter.name"/><fmt:message key="common.colon"/></td>
		<td class="usertablerow2">
			<input type="text" name="name" value="${chapterCommand.name }"/>
			<span class="error">*</span>
			<form:errors path="name" cssClass="error"/>
		</td>
		<td class="usertablerow2"><fmt:message key="book.chapter.type"/><fmt:message key="common.colon"/></td>
		<td class="usertablerow2">
			<c:forEach items="${chapterCommand.chapterTypeList}" var="varType">
				<c:choose>
					<c:when test="${varType == chapterCommand.type}">
						<input checked="checked" type="radio" name="type" value="${varType}"/><fmt:message key="book.chapter.type.${varType}"/> 
					</c:when>
					<c:otherwise>
						<input type="radio" name="type" value="${varType}"/><fmt:message key="book.chapter.type.${varType}"/>
					</c:otherwise>
				</c:choose>
			</c:forEach>
			<span class="error">*</span>
			<form:errors path="type" cssClass="error"/>
		</td>
	</tr>
	<tr>
		<td class="usertablerow2"><fmt:message key="book.chapter.order"/><fmt:message key="common.colon"/></td>
		<td class="usertablerow2">
			<input type="text" name="order" value="${chapterCommand.order }"/>
			<span class="error">*</span>
			<form:errors path="order" cssClass="error"/>
		</td>
		<td class="usertablerow2"><fmt:message key="book.dir"/><fmt:message key="common.colon"/></td>
		<td class="usertablerow2">
			<input type="text" name="path" value="<c:out value="${chapterCommand.path }"/>" size="11"/>
			<span class="error">*</span>
			<form:errors path="path" cssClass="error"/>
		</td>
	</tr>
	<tr>
		<td class="usertablerow2"><fmt:message key="book.chapter.description"/><fmt:message key="common.colon"/></td>
		<td class="usertablerow2" colspan="5"><textarea cols="60" rows="3" name="description" id="description"><c:out value="${chapterCommand.description}"/></textarea></td>
	</tr>
	<tr>
		<td class="usertablerow2" colspan="6" align="center">
			<input type="submit" value="<fmt:message key="common.submit"/>"/>
			<input type="button" value="<fmt:message key="common.back"/>" onclick="window.location='${ctx}/admin/book/edit.do?id=${chapterCommand.bookId }';"/>
		</td>
	</tr>
</table>
</form:form>

<br/>
<form:form action="${ctx }/admin/bookChapter/upload.do" method="post" enctype="multipart/form-data" commandName="chapterCommand">
<input name="bookId" type="hidden" value="${chapterCommand.bookId }"/>
<input name="chapterId" type="hidden" value="${chapterCommand.chapterId }"/>
<input name="order" type="hidden" value="${chapter.itemCount }"/>
<table class="usertableborder" cellspacing="1" cellpadding="3" width="96%" align="center" border="0">
	<tr>
		<td class="usertablerow2"><fmt:message key="common.upload"/></td>
		<td class="usertablerow2">
			<input type="file" name="item" size="40"/>
			<input type="submit" value="<fmt:message key="common.upload"/>"/>
		</td>
	</tr>
</table>
</form:form>

<c:if test="${chapter.itemCount>0}">
<br/>
<table class="usertableborder" cellspacing="1" cellpadding="3" width="96%" align="center" border="0">
	<c:forEach items="${chapter.bookItems}" var="item" varStatus="index">
	<form:form action="${ctx }/admin/bookChapter/order.do" method="post" commandName="chapterCommand">
	<input name="bookId" type="hidden" value="${chapterCommand.bookId }"/>
	<input name="chapterId" type="hidden" value="${chapterCommand.chapterId }"/>
	<input name="itemId" type="hidden" value="${item.id }"/>
	<tr>
		<td class="usertablerow2"><c:out value="${item.id}"/></td>
		<td class="usertablerow2"><c:out value="${item.name}"/></td>
		<td class="usertablerow2"><input type="text" name="order" value="${item.order }"/></td>
		<td class="usertablerow2"><input type="submit" value="<fmt:message key="common.submit"/>"/></td>
		<td class="usertablerow2"><input type="button" value="<fmt:message key="common.delete"/>" onclick="window.location='${ctx}/admin/bookChapter/removeItem.do?bookId=${chapterCommand.bookId }&chapterId=${chapterCommand.chapterId }&itemId=${item.id }';"/></td>
	</tr>
	</form:form>
	</c:forEach>
</table>
</c:if>

<br/>
</body>
</html>